package com.itany.lambda;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @Author:石小俊
 * @Date:2022/11/17 11:49
 * @Version:1.0-SNAPSHOT
 * @Description: 构造方法引用
 */
public class Test04 {

    public static void main(String[] args) {
        // 调用无参构造
        Supplier<User> s = User::new;
        User user = s.get();
//        System.out.println(user);
        System.out.println(user.getUsername()+"--"+user.getPassword());

        // 调用单参数构造
        Function<String,User> f = User::new;
        User user2 = f.apply("admin");
//        System.out.println(user2.getUsername());
        System.out.println(user2.getUsername()+"--"+user2.getPassword());

        // 调用两个参数构造
        BiFunction<String,String,User> bf = User::new;
        User user3 = bf.apply("admin","123456");
        System.out.println(user3.getUsername()+"--"+user3.getPassword());
    }

}
